
extern "C" {
    pub type _IO_wide_data;
    pub type _IO_codecvt;
    pub type _IO_marker;
    fn getc(__stream: *mut FILE) -> i32;
    fn calloc(_: u64, _: u64) -> *mut ();
    fn free(_: *mut ());
    fn reallocarray(__ptr: *mut (), __nmemb: size_t, __size: size_t)
        -> *mut ();
    fn __errno_location() -> *mut i32;
}
pub type size_t = u64;
pub type __off_t = i64;
pub type __off64_t = i64;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct _IO_FILE {
    pub _flags: i32,
    pub _IO_read_ptr: *mut i8,
    pub _IO_read_end: *mut i8,
    pub _IO_read_base: *mut i8,
    pub _IO_write_base: *mut i8,
    pub _IO_write_ptr: *mut i8,
    pub _IO_write_end: *mut i8,
    pub _IO_buf_base: *mut i8,
    pub _IO_buf_end: *mut i8,
    pub _IO_save_base: *mut i8,
    pub _IO_backup_base: *mut i8,
    pub _IO_save_end: *mut i8,
    pub _markers: *mut _IO_marker,
    pub _chain: *mut _IO_FILE,
    pub _fileno: i32,
    pub _flags2: i32,
    pub _old_offset: __off_t,
    pub _cur_column: u16,
    pub _vtable_offset: i8,
    pub _shortbuf: [i8; 1],
    pub _lock: *mut (),
    pub _offset: __off64_t,
    pub _codecvt: *mut _IO_codecvt,
    pub _wide_data: *mut _IO_wide_data,
    pub _freeres_list: *mut _IO_FILE,
    pub _freeres_buf: *mut (),
    pub __pad5: size_t,
    pub _mode: i32,
    pub _unused2: [i8; 20],
}
pub type _IO_lock_t = ();
pub type FILE = _IO_FILE;
#[no_mangle]
pub extern "C" fn fgetln(mut fp: *mut FILE, mut len: *mut size_t) -> *mut i8 {
    static mut buf: *mut i8 = 0 as *const i8 as *mut i8;
    static mut bufsz: size_t = 0 as size_t;
    let mut r: size_t = 0 as size_t;
    let mut p: *mut i8 = std::ptr::null_mut::<i8>();
    let mut c: i32 = 0;
    let mut e: i32 = 0;
    if fp.is_null() || len.is_null() {
        (unsafe { *__errno_location() = 22 });
        return std::ptr::null_mut::<i8>();
    }
    if (unsafe { buf }).is_null() {
        (unsafe { buf = calloc(1 as i32 as u64, 8192 as u64) as *mut i8 });
        if (unsafe { buf }).is_null() {
            return std::ptr::null_mut::<i8>();
        }
        (unsafe { bufsz = 8192 as size_t });
    }
    loop {
        c = unsafe { getc(fp) };
        if c == -(1 as i32) {
            break;
        }
        let fresh0 = r;
        r = r.wrapping_add(1);
        (unsafe { *buf.offset(fresh0 as isize) = c as i8 });
        if r == (unsafe { bufsz }) {
            p = (unsafe { reallocarray(buf as *mut (), 2 as size_t, bufsz) })
                as *mut i8;
            if p.is_null() {
                e = unsafe { *__errno_location() };
                (unsafe { free(buf as *mut ()) });
                (unsafe { *__errno_location() = e });
                (unsafe { buf = std::ptr::null_mut::<i8>() });
                (unsafe { bufsz = 0 as size_t });
                return std::ptr::null_mut::<i8>();
            }
            (unsafe { buf = p });
            (unsafe { bufsz = (2 as i32 as u64).wrapping_mul(bufsz) });
        }
        if c == '\n' as i32 {
            break;
        }
    }
    (unsafe { *len = r });
    return if (unsafe { *len }) != 0 {
        unsafe { buf }
    } else {
        std::ptr::null_mut::<i8>()
    };
}
